import {Component} from "react";
import {RichText, View, Text} from "@tarojs/components";
import './topicinfo.less'
import {myTimeToLocal} from "../../utils/date";

class Topicinfo extends Component {

  render() {
    // @ts-ignore
    const {topicinfo} = this.props;
    return (
      <View className='topicinfo'>
        <View className='topicinfo__header'>
          <View className='topicinfo__header-title'>
            {topicinfo.top
              ? <Text className='topic-up'>置顶</Text>
              : (topicinfo.tab == 'share'
                ? <Text className='topic-up blue'>分享</Text>
                : <Text className='topic-up blue'>问答</Text>)
            }
            <Text className='topic-title'>{topicinfo.title}</Text>
          </View>
          <View className='topicinfo__header-pie'>
            <Text>·{myTimeToLocal(topicinfo.create_at)}</Text>
            <Text>·{topicinfo.author ? topicinfo.author.loginname : ''}</Text>
            <Text>·{topicinfo.visit_count + '次浏览'}</Text>
          </View>
        </View>
        <View className='topicinfo__content'>
          <RichText nodes={topicinfo.content} />
        </View>
      </View>
    );
  }
}
export default Topicinfo
